<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: header"></head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<title>欢迎参加培训会议</title>
<style>
	body{background-color: #fafafa}
	.title{padding: 10px 0;border-bottom: 1px solid #eee;text-align: center;}
	.bottomBtnGroup{text-align: center;margin-bottom: 20px}
	::-webkit-scrollbar{display: none}
</style>

<body>

	<div class="container">
		<h3 class="title">欢迎参加培训会议</h3>
        <form class="form-horizontal m" id="form-meetingSystem-add">
			<div class="form-group">	
				<label class="col-xs-12 col-sm-3 col-md-3 col-lg-3 control-label" for="userName"><span style="color: red; ">*</span>参会者姓名：</label>
				<div class="col-xs-12 col-sm-7 col-md-7 col-lg-7">
					<input id="userName" name="userName" class="form-control" type="text" autocomplete="off" required>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-xs-12 col-sm-3 col-md-3 col-lg-3 control-label" for="phone"><span style="color: red; ">*</span>手机号：</label>
				<div class="col-xs-12 col-sm-7 col-md-7 col-lg-7">
					<input id="phone" name="phone" class="form-control" type="tel" maxlength="11" autocomplete="off" required>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-xs-12 col-sm-3 col-md-3 col-lg-3 control-label" for="teamName"><span style="color: red; ">*</span>队名/组名：</label>
				<div class="col-xs-12 col-sm-7 col-md-7 col-lg-7">
					<input id="teamName" name="teamName" class="form-control" type="text"  autocomplete="off">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-xs-12 col-sm-3 col-md-3 col-lg-3 control-label" for="statusRoleId"><span style="color: red; ">*</span>培训角色：</label>
				<div class="col-xs-12 col-sm-7 col-md-7 col-lg-7">
					<select name="statusRoleId" id="statusRoleId" th:with="type=${@dict.getType('role_type')}" class="form-control">
						<option value="">所有</option>
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-xs-12 col-sm-3 col-md-3 col-lg-3 control-label" for="teamCall">队呼 ：</label>
				<div class="col-xs-12 col-sm-7 col-md-7 col-lg-7">
					<textarea id="teamCall" name="teamCall" class="form-control" rows="3" style="resize:none"></textarea>
				</div>
			</div>

			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-3 col-lg-3 control-label" for="companyName"> 公司名称 ：</label>
				<div class="col-xs-12 col-sm-7 col-md-7 col-lg-7">
					<textarea id="companyName" name="companyName" class="form-control" rows="2" style="resize:none"></textarea>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-3 col-lg-3 control-label" for="companyPost"> 所属职位 ：</label>
				<div class="col-xs-12 col-sm-7 col-md-7 col-lg-7">
					<textarea id="companyPost" name="companyPost" class="form-control" rows="2" style="resize:none"></textarea>
				</div>
			</div>
		</form>
		<div class="">
			<div class="col-lg-12 bottomBtnGroup">
				<button type="button" class="btn btn-sm btn-default" onclick="closeItem()" style="margin-right: 10px"><i class="fa fa-reply"></i>关 闭 </button>
				<button type="button" class="btn btn-sm" onclick="submitHandler()" style="margin-left: 10px;background-color: #FDCF3B;"><i class="fa fa-check"></i>保 存</button>
			</div>
		</div>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "system/meetingSystem"
		$("#form-meetingSystem-add").validate({
			rules:{
				userName:{
					required:true,
				},
				phone:{
					required:true,
					minlength: 11,
					digits:true
				},
				teamName:{
					required:true,
				},
				statusRoleId:{
					required:true,
				}

			},
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        /*    $.operate.save(prefix + "/addMerting", $('#form-meetingSystem-add').serialize());*/
				add();
	        }
	    }
	    function closeItem() {
			location.href="/system/meetingSystem/kai"
		}

		function add(){
		    var userName =	$("input[name='userName']").val();
			var phone =	$("input[name='phone']").val();
			var statusRoleId = $("select[name='statusRoleId'] option:selected").val();
			var teamName =	$("input[name='teamName']").val();
			var teamCall =	$("textarea[name='teamCall']").val();
			var companyName =	$("textarea[name='companyName']").val();
			var companyPost =	$("textarea[name='companyPost']").val();
               $.ajax({
				   type:'POST',
				   url:prefix + "/addMerting",
				   data: {
				   	   "userName":userName,
				   	   "phone":phone,
					   "statusRoleId":statusRoleId,
					   "teamName":teamName,
					   "teamCall":teamCall,
                       "companyName":companyName,
                       "companyPost":companyPost
				   },
                   async : false,
                   success : function(re) {
                       if (re.code==2){
						   layer.open({
							   type: 0,
							   content: '当前手机号已被已被注册',
							   yes: function(index, layero){
								   layer.close(index);
							   }
						   });
                       }else{
                           location.href=  prefix+"/to"
                       }
                   }
			   });
		}
	</script>
</body>
</html>
